package cn.yj.frame.spring;

import cn.yj.frame.annotation.RpcService;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
import org.springframework.core.type.filter.AnnotationTypeFilter;

import java.util.Set;

/**
 * 自定义扫描器，用于扫描我们的自定义注解 @RpcService
 * @author 永健
 * @since 2022-01-18 15:24
 */
public class YJClassPathScanner extends ClassPathBeanDefinitionScanner {

    public YJClassPathScanner(BeanDefinitionRegistry registry) {
        super(registry);
    }

    @Override
    protected Set<BeanDefinitionHolder> doScan(String... basePackages) {
        // 自定义扫描规则
        resetFilters(false);
        addIncludeFilter(new AnnotationTypeFilter(RpcService.class));
        return super.doScan(basePackages);
    }
}
